GAD
A GAD (GA'me '''D'ata) file is used by the Thanatos Engine, which runs Age of Prisoners, to store game data, such as shaders, scripts, mazes, etc. It is an archive file, and therefore it stores a bunch of files inside it. Up to Thanatos 0.0.7, a format now called "GADv1" was used; a new one is planned for Thanatos 0.0.8, named "GADv2". Due to the increasing size of those files as the game is being developed, GADv2 will be compressed. Archive Contents At the root of a GAD archive, there is a number of directories, and inside those directories, there are files that describe a game. This section of the article will describe those files. Bitmaps The bitmaps directory simply contains images used by the game, and by the engine. Some are required to be there, others are optional, and depend on whether they are needed due to settings in other files. Cutscenes The cutscenes directory contains scripts that describe what to do for each cutscene. Fonts The fonts directory contains ME-formatted fonts used in the game. As of 0.0.7 and 0.0.8, they are all required. GUI The gui directory contains sub-directories, each specifying the workings of a different GUI. Some GUI are required, but may be customized. In each of those sub-directories, there are 4 files that describe a GUI: *control.mzs: A script which tells the engine what to do for various events related to the GUI. *layout.info: Contains lines in the format x1:x2:y1:y2:signal, where the coordinates define a rectangle for a button, and signal names a procedure in the control.mzs file that is to be called when the button is clicked. *window.png: The image of the window of the GUI. All buttons are drawn on top. *overlay.png: An image, the same size as window.png, to be drawn on top of the buttons. Mazes The mazes directory contains the mazes for the game. Each one is named FLOOR_NUMBER.maz. Misc The misc directory contains the following files: *gameinfo.dat: This file contains information about the game. *intro.txt: This file contains the intro text. *rc.xml: This file specifies game resources, such as materials and sounds. *shader.frag/shader.vert: Fragment & Vertex Shader templates. *tag.info: Tag information for the maze editor. Phone The phone directory contains phone conversation files. Scripts The scripts directory contains scripts for controlling mazes, named FLOOR_NUMBER.mzs, as well as a script for controlling the entire game, global.mzs. Shops The shops directory contains XML files that describe shops. Sounds The sounds directory contains WAVE-formatted sound files. Weapons The weapons directory contains images of weapons' bullets, normal and shooting overlays. For Thanatos 0.0.8+, we are planning to also add a weapon model there, for multiplayer games (so that players can see each other's weapons). GADv1 GADv1 files contain a list of directories and files, and the file data. The file data is plain - no compression is involved. This section describes the structure of GADv1 files. GADv1 Header Right at the beginning of a file, you find a GADv1 Header, which is a structure that gives basic information about the file. '''NOTE: A UNIX timestamp is the number of seconds since midnight, 1 January 1970 UTC. Directory List Right after the header, there is a list of directory names, separated by NULs. The list is sorted such that a directory's children always come after the parent. File List Right after the directory list, there is a file list. Each entry has a "file header", followed by a NUL-terminated file name, followed by the contents, whose size is specified by the header. GADv2 GADv2 is a format planned for Thanatos 0.0.8, which adds support for compression. It is very similar to GADv1 in many ways, but different in others. This section describes this format. GADv2 Header Right at the beginning of a file, we have a GADv2 Header, which is almost the same as the GADv1 header, but please note the differences! Empty Directory List Right after the header, there is a list of empty directories; directories with content are not listed, because they can be extracted from file names, e.g. "misc" can be extracted from the fact that there is a "misc/rc.xml" file. File List Each entry in the file list is, yet again, made up of a "file header", a NUL-terminated file name, and the compressed file contents. The file header is also different: Compression GADv2 archives are compressed, and each file may have a different compression format. All the formats follow the same idea. You have a mapping of 'compressed bits', to "plain content". An example mapping could be: *0 -> 11011011 *10 -> 11011100 *11 -> 11100011 Each format just has a different mapping. When you have a mapping, you can decompress a stream with the following algorythm (here I wrote it in pseudo-code): while (input waiting) { BitStream temp; while (no mapping for temp) { temp += getBitFromInput(); }; output += getMapping(temp); }; The rest of this section gives the mappings for various formats. Format 0 (CF_NONE) There is no compression - the file is given in plain data. Format 1 (CF_RC_XML_1) This is revision one of the format used by default to compress the file misc/rc.xml. Bytes above 127 are not supported by this compression, as they should never legally appear in misc/rc.xml.